/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.wpilibj.templates.subsystems;

import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.templates.RobotMap;
import edu.wpi.first.wpilibj.templates.commands.StopBallHandling;

/**
 *
 * @author Jared
 */
public class BallHandling extends Subsystem {
    private static BallHandling instance = null;
    private DoubleSolenoid stopper = new DoubleSolenoid(RobotMap.BALL_STOPPER_SOLENOID_FWD, RobotMap.BALL_STOPPER_SOLENOID_REV);
    private DoubleSolenoid potty_chair = new DoubleSolenoid(RobotMap.POTTY_CHAIR_SOLENOID_FWD, RobotMap.POTTY_CHAIR_SOLENOID_REV);
    private Relay collector = new Relay(RobotMap.BALL_ELEVATOR_SPIKE);
    
    // Put methods for controlling this subsystem
    // here. Call these from Commands.
    public static BallHandling getInstance() {
        if(instance == null){
            instance = new BallHandling();   
        }
        return instance;
    }
    
    private BallHandling(){
        collector.setDirection(Relay.Direction.kBoth);
    }
    
    public void collectBalls(){
        potty_chair.set(DoubleSolenoid.Value.kReverse); //down
        stopper.set(DoubleSolenoid.Value.kForward);  //stopping
        collector.set(Relay.Value.kForward); //collecting        
    }
    
    public void cycleBalls(){
        potty_chair.set(DoubleSolenoid.Value.kReverse); //down
        stopper.set(DoubleSolenoid.Value.kReverse);  //release
        collector.set(Relay.Value.kForward); //collecting
        
    }
    public void shootBall(){
        potty_chair.set(DoubleSolenoid.Value.kForward); //up
        
    }
    
    public void reverseElevator(){
     collector.set(Relay.Value.kReverse); //collecting   
    }
    public void stopBallHandling() {
        potty_chair.set(DoubleSolenoid.Value.kReverse); //down
        stopper.set(DoubleSolenoid.Value.kForward);  //release
        collector.set(Relay.Value.kOff); //collecting
        
    }
    
    public void initDefaultCommand() {
        setDefaultCommand(new StopBallHandling());
        // Set the default command for a subsystem here.
        //setDefaultCommand(new MySpecialCommand());
    }
}
